package com.twu.biblioteca.models;


import java.util.Arrays;

public class User {
    private String number;
    private byte[] password;
    private String name;
    private String email;
    private String phone;

    public User(String number, byte[] password, String name, String email, String phone) {
        if(number == null || password == null || number.equals("") || !number.matches("\\d{3}-\\d{5}") || !email.matches("[a-z]*@[a-z]*\\.[a-z]*")){
            throw new IllegalArgumentException();
        }

        this.number = number;
        this.password = password;
        this.name = name;
        this.email = email;
        this.phone = phone;
    }

    @Override
    public String toString() {
        return this.number;
    }

    public boolean equals(User obj) {
        if(this.getNumber().equals(obj.getNumber()) && Arrays.equals(this.password, obj.password)){
            return true;
        }
        else{
            return false;
        }
    }

    public String getNumber() {
        return number;
    }

    public byte[] getPassword() {
        return password;
    }

    public String getName() {
        return name;
    }

    public String getEmail() {
        return email;
    }

    public String getPhone() {
        return phone;
    }
}
